package example.book.server;

import example.book.enums.BookStatus;
import example.book.mapper.BookInfoMapper;
import example.book.model.BookInfos;
import example.book.model.PageRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class BookServer {
    public List<BookInfos> getBookList(PageRequest pageRequest) {
        List<BookInfos> books = bookInfoMapper.queryBookMapper(pageRequest);
        for (BookInfos book : books) {
           book.setStateCN(BookStatus.getNameByCode(book.getStatus()).getName());
        }
        return books;
    }
    @Autowired
    BookInfoMapper bookInfoMapper;
    public void addBook(BookInfos bookInfos) {
        bookInfoMapper.addBook(bookInfos);
    }
}
